//
//  EmotionPopView.m
//  Weibo
//
//  Created by Anasue on 9/28/15.
//  Copyright © 2015 vvusu. All rights reserved.
//

#import "EmotionPopView.h"
#import "EmotionView.h"

@interface EmotionPopView ()
@property (weak, nonatomic) IBOutlet EmotionView *emotionView;

@end

@implementation EmotionPopView
+ (instancetype)popView
{
    return [[[NSBundle mainBundle]loadNibNamed:@"EmotionPopView" owner:nil options:nil]lastObject];
}

- (void)showPopView:(EmotionView *)fromEmotionView
{
    self.emotionView.emotion = fromEmotionView.emotion;
    UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
    [window addSubview:self];
    CGFloat centerX = fromEmotionView.centerX;
    CGFloat centerY = fromEmotionView.centerY - self.height * 0.5;
    CGPoint center = CGPointMake(centerX, centerY);
    self.center = [window convertPoint:center fromView:fromEmotionView.superview];
}

- (void)dismiss
{
    [self removeFromSuperview];
}

- (void)drawRect:(CGRect)rect
{
    [[UIImage imageWithName:@"emoticon_keyboard_magnifier"] drawInRect:rect];
}



@end
